package com.kgc.sbt.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jms.annotation.EnableJms;
import org.springframework.jms.config.JmsListenerContainerFactory;
import org.springframework.jms.config.SimpleJmsListenerContainerFactory;

import javax.jms.ConnectionFactory;

/**
 * Created on 2021/6/21.
 * <p>
 * Author: GongMingJie
 * <p>
 * Description: activemq消息配置类
 */
@Configuration
public class ActiveMqConfig {

    /**
     * Created on 2021/6/11
     * Author: GongMingJie
     * @param
     * @return
     * Description: 模式-点对点
     */
    @Bean
    public JmsListenerContainerFactory queueJmsListenerContainerFactory(ConnectionFactory connectionFactory){
        SimpleJmsListenerContainerFactory containerFactory = new SimpleJmsListenerContainerFactory();
        containerFactory.setConnectionFactory(connectionFactory);
        containerFactory.setPubSubDomain(false);
        return containerFactory;
    }

    /**
     * Created on 2021/6/11
     * Author: GongMingJie
     * @param
     * @return
     * Description: 模式-topic主题
     */
    @Bean
    public JmsListenerContainerFactory topicJmsListenerContainerFactory(ConnectionFactory connectionFactory){
        SimpleJmsListenerContainerFactory containerFactory = new SimpleJmsListenerContainerFactory();
        containerFactory.setConnectionFactory(connectionFactory);
        containerFactory.setPubSubDomain(true);
        return containerFactory;
    }
}
